# -*- mode: python -*-

Import("env")

env.SConscript(
    dirs=[
        'legacy',
        'replset',
    ],
)

env.Library(
    target='catalog_types',
    source=[
        'type_changelog.cpp',
        'type_chunk.cpp',
        'type_collection.cpp',
        'type_config_version.cpp',
        'type_database.cpp',
        'type_lockpings.cpp',
        'type_locks.cpp',
        'type_mongos.cpp',
        'type_settings.cpp',
        'type_shard.cpp',
        'type_tags.cpp',
    ],
    LIBDEPS=[
        'mongo_version_range',
        '$BUILD_DIR/mongo/base',
        '$BUILD_DIR/mongo/bson/util/bson_extract',
        '$BUILD_DIR/mongo/db/common',
    ]
)

env.Library(
    target='mongo_version_range',
    source=[
        'mongo_version_range.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/base',
    ]
)

env.Library(
    target='catalog_manager',
    source=[
        'catalog_cache.cpp',
        'catalog_manager_common.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/base',
        '$BUILD_DIR/mongo/db/common',
        '$BUILD_DIR/mongo/s/write_ops/batch_write_types',
        '$BUILD_DIR/mongo/s/common',
        '$BUILD_DIR/mongo/s/catalog/catalog_types',
        '$BUILD_DIR/mongo/s/client/sharding_client',
        '$BUILD_DIR/mongo/s/shard_util',
        'dist_lock_manager',
    ],
    LIBDEPS_TAGS=[
        # Circular with coreshard for mongo::grid and mongo::DBConfig.
        'incomplete',
    ],
)

env.Library(
    target='forwarding_catalog_manager',
    source=[
        'forwarding_catalog_manager.cpp'
    ],
    LIBDEPS=[
        'catalog_manager',
        'legacy/catalog_manager_legacy',
        'replset/catalog_manager_replica_set',
        'replset/dist_lock_catalog_impl',
        'replset/replset_dist_lock_manager',
    ]
)

env.Library(
    target='catalog_manager_mock',
    source=[
        'catalog_manager_mock.cpp',
    ],
    LIBDEPS=[
        'catalog_manager',
        'dist_lock_manager_mock',
    ]
)

env.CppUnitTest(
    target='catalog_types_test',
    source=[
        'type_changelog_test.cpp',
        'type_chunk_test.cpp',
        'type_collection_test.cpp',
        'type_config_version_test.cpp',
        'type_database_test.cpp',
        'type_lockpings_test.cpp',
        'type_locks_test.cpp',
        'type_mongos_test.cpp',
        'type_settings_test.cpp',
        'type_shard_test.cpp',
        'type_tags_test.cpp',
    ],
    LIBDEPS=[
        'catalog_types'
    ]
)

env.Library(
    target='dist_lock_manager',
    source=[
        'dist_lock_manager.cpp',
        'dist_lock_ping_info.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/base',
    ],
)

env.Library(
    target='dist_lock_manager_mock',
    source=[
        'dist_lock_manager_mock.cpp',
    ],
    LIBDEPS=[
        'dist_lock_manager',
        '$BUILD_DIR/mongo/unittest/unittest',
    ],
)

env.Library(
    target='dist_lock_catalog_interface',
    source=[
        'dist_lock_catalog.cpp',
    ],
    LIBDEPS=[
    ],
)

env.Library(
    target='dist_lock_catalog_mock',
    source=[
        'dist_lock_catalog_mock.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/unittest/unittest',
        'catalog_types',
        'dist_lock_catalog_interface',
    ]
)
